package com.cavy.platform.server.domain;

import lombok.Data;

@Data
public class PluginEnvironment extends AbstractRegexp {
    private String name;
    private String value;
    private String tips;
    private String label;

    /**
     * 1,名称一致
     * 2,值符合正则表达式
     */
    public ValidateError validate(ContainerEnvironmentData data) {
        if (!name.equals(data.getName())) {
            return new ValidateError("环境变量与插件不一致", data.getNameFieldName());
        }
        boolean b = validateValue(data.getValue());
        if (!b) {
            return new ValidateError("环境变量值格式有误", data.getValueFieldName());
        }
        return null;
    }
}
